package erfgame.core.util;


import erfgame.core.util.ArrayUtils;
import erfgame.core.world.terrain.TerrainUtils;

import static org.junit.Assert.assertTrue;

import org.junit.Test;


public class TerrainSummaryTester {

	@Test
	public void testSurfaceSummary1() {
		int width = 2;
		int height = 2;
		short[][][] terrain = new short[][][]{
				{
					{1,1},
					{1,1},
				},{
					{1,1},
					{1,1}
				}
		};
		int[][][] surfaces = new int[width][height][];
		TerrainUtils.deriveTerrainSummary(terrain, surfaces, width, height);
		
		int[][][] expected = new int[][][]{
				{
					{2},
					{2}
				},{
					{2},
					{2}
				}
		};
		assertTrue( ArrayUtils.equals( surfaces, expected ) );
	}
	
	@Test
	public void testSurfaceSummary2() {
		int width = 2;
		int height = 2;
		short[][][] terrain = new short[][][]{
				{
					{1,1},
					{1,0},
				},{
					{1,1},
					{0,1}
				}
		};
		int[][][] surfaces = new int[width][height][];
		TerrainUtils.deriveTerrainSummary(terrain, surfaces, width, height);
		
		int[][][] expected = new int[][][]{
				{
					{2},
					{1,1}
				},{
					{2},
					{1,1}
				}
		};
		assertTrue( ArrayUtils.equals( surfaces, expected ) );
	}

	@Test
	public void testSurfaceSummary3() {
		int width = 2;
		int height = 2;
		short[][][] terrain = new short[][][]{
				{
					{1,1,0,0,1,1},
					{1,2,3,4,5},
				},{
					{1},
					{1,1,0}
				}
		};
		int[][][] surfaces = new int[width][height][];
		TerrainUtils.deriveTerrainSummary(terrain, surfaces, width, height);
		
		int[][][] expected = new int[][][]{
				{
					{2,2,2},
					{1,1,1,1,1}
				},{
					{1},
					{2,1}
				}
		};
		assertTrue( ArrayUtils.equals( surfaces, expected ) );
	}

}
